package com.minelx.sqlstructures.statements.parse.select;

import com.minelx.sqlstructures.statements.SelectBuilder;
import com.minelx.sqlstructures.statements.clause.AndBuilder;
import com.minelx.sqlstructures.statements.clause.SelectClauseBuilder;
import com.minelx.sqlstructures.statements.clause.Sql;

import java.util.Scanner;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toList;

public class MainTest {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			System.out.print("input select: ");
			SelectBuilderParser parser = new SelectBuilderParser();
			SelectBuilder parsed = parser.parse(scanner.nextLine());

			AndBuilder where = parsed.where();
			System.out.println("where -> " + where.build());
			System.out.println("where.conditions() = " + where.conditions());

			SelectClauseBuilder select = parsed.select();
			System.out.println("select = " + select.build().toText());
			System.out.println("select.tableName = " + select.getTableName());
			System.out.println("fields = " + select.getFields().stream().map(Sql::toText).collect(toList()));
		}
	}
}
